using Framework.Core.CommandLine;

namespace Framework.Core.BootStrapper
{
    public abstract class PluginBase<T> : IPlugin<T>
        where T : PluginCommandLineArgs
    {
        private readonly ICommandLineParser commandLineParser;

        protected PluginBase()
            : this(new CommandLineParser())
        {
        }

        private PluginBase(ICommandLineParser commandLineParser)
        {
            this.commandLineParser = commandLineParser;
        }

        public abstract int Execute(T args);

        public int Execute(string[] args)
        {
            return Execute(commandLineParser.Parse<T>(args));
        }
    }
}